import {Injectable} from '@angular/core';
import {Http, ResponseContentType}from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class DataService {
  users: string[];

  constructor(public http: Http) {
    this.users = ["mr.li", "17", "liqiao"]
  }

  getUsers() {
    // return this.http.get("http://jsonplaceholder.typicode.com/users")
    return this.http.get("http://127.0.0.1:8080/user")
      .map(res => res.json());

  }

  addUser(user) {
    return this.http.post("http://127.0.0.1:8080/user/add", user)
      .map(res => res.json());
  }

  deleteUser(id){
    return this.http.get("http://127.0.0.1:8080/user/delete/"+id)
      .map(res => res.json());
  }
}
